<template>
  <div>
    <el-form-item
      :label="parentNoTitle"
      label-width="150px"
      class="normal-type"
      v-if="$store.state.edit.row.level != 1"
    >
      <div slot="label">
        <span style="color:red">*</span>{{ parentNoTitle }}
      </div>
      <el-select
        style="width: 80%"
        v-model="$store.state.edit.row.parentNo"
        filterable
        default-first-option
        clearable
        :placeholder="placeholder"
        :remote="row.search"
      >
        <el-option
          v-for="(label,value) in $store.state.edit.entry.sources['financeSubjectOneSource ' + ($store.state.edit.row.level - 1)]"
          :key="value"
          :label="label"
          :value="value"
        >
        </el-option>
      </el-select>
    </el-form-item>
  </div>
</template>

<script>
import { m, notify } from "@/store/yg/common/local";
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";

export default {
  data() {
    return {
      parentNoTitle: "",
      placeholder: "",
      row: {},
      loadingPort: [{ required: true, message: "必填", trigger: "change" }]
    };
  },
  beforeCreate(){
    
  },
  created() {
    this.row = this.$store.state.edit.row;
    this.placeholder = m("please_select");
    this.parentNoTitle = m("subject_parent_no");
    this.initParentNoData();
  },

  methods: {
    initParentNoData() {
      var level = this.row.level - 1;
      this.$store.dispatch("loadEditOptionSource", { bean: "financeSubjectOneSource", arg: level, cached: false , dependency: true});
      
    },

    callvalidate() {
      if (
        (this.$store.state.edit.row["parentNo"] == "" || this.$store.state.edit.row["parentNo"] == null) && 
        this.$store.state.edit.row["level"] != 1
      ) {
        notify({
          message: m("field") + ": parentNo " + m("required"),
          type: "error",
          duration: 10000,
          dangerouslyUseHTMLString: true,
          position: "bottom-right"
        });
        return false;
      }

      return true;
    },
    callbefore() {
      //console.log("2222" + JSON.stringify(this.$store.state.edit.entry.sources))
    

      //console.log('111111111111111111111111',this.$store.state.edit.row);

      // for (var i in this.$store.state.edit.entry.panel.content) {
      //   var c = this.$store.state.edit.entry.panel.content[i];
      //   for (var j in c.column) {
      //     var row = c.column[j];
      //     if (!row.field) {
      //       row.field = "parentNo";
      //     }
      //   }
      // }

    }
  }
};
</script>

<style>
.mail {
  text-align: left;
}
.normal-type .el-form-item__content {
  padding: 0 5px 0 15px;
}
</style>
